<?

function print_query($query,$conn,$heading=1,$border=1,$threshold=0) {

  $curs = ora_open($conn);

  ora_commitoff($conn);

  // execute query
  ora_parse($curs, $query);
  ora_exec($curs);

  $ncols = ora_numcols($curs);

  // print out results

  if($ncols > 0 ) {
    ?><table border="<?php echo $border?>"><?
    if($heading) {
      printf("<tr>");
      for ($i=0; $i<$ncols; $i++) {
        printf("<th>%s</th>", ora_columnname($curs, $i));
      }
      printf("</tr>");
    }

    while (ora_fetch($curs)) {
      printf("<tr>");
        for ($i=0; $i<$ncols; $i++) {
        $col = ora_getcolumn($curs, $i);
        printf("<td>%s</td>", $col?nl2br($col):"&nbsp;");
      }
      printf("</tr>");
    }
  } //cols > 0
  ora_close($curs);
 ?>
</table><br />
<?php } ?>